package com.wwlwxg.bloomFilter;

import com.google.common.hash.BloomFilter;

class BloomFilterSample{
  public static void main(String[] args) {
        // 创建一个BloomFilter，其预计插入的个数为10，误判率大约为0.01
        BloomFilter<Person> bloomFilter = BloomFilter.create(PersonFunnel.INSTANCE, 10, 0.01);
        // 查询new Person("chen", "yahui")是否存在
        System.out.println(bloomFilter.mightContain(new Person("chen", "yahui"))); //false
        // 将new Person("chen", "yahui")对象放入BloomFilter中
        bloomFilter.put(new Person("chen","yahui"));
        // 再次查询new Person("chen", "yahui")是否存在
        System.out.println(bloomFilter.mightContain(new Person("chen", "yahui"))); //true


  }
}